//
//  unittest3.c
//  Dominion
//
//  Eric Hook
//  hooke@onid.orst.edu
//  CS362 Winter 2014
//

#include "dominion.h"
#include "dominion_helpers.h"
#include <string.h>
#include <stdio.h>
#include <assert.h>
#include "rngs.h"

int seed = 1000;
int k[10] = {adventurer, council_room, feast, gardens, mine, remodel, smithy, village, baron, great_hall};

void testShuffleWithZeroToFiveHundredCardsInDeck() {
    int expectedResult=-1;
    int actualResult=0;
    int result = 0;
    struct gameState G;
    
    printf ("TESTING: shuffle(int player, struct gameState *state) : unittest3.c.\n");
  
    memset(&G, 23, sizeof(struct gameState));       // clear the game state

    result = initializeGame(2, k, seed, &G);
    
    G.deckCount[0] = 0;                             // bad shuffle
    
    actualResult = shuffle(0, &G);                  // shuffle checks that -1 returned with 0 card in player hand
    
    assert(actualResult == expectedResult);         // checks return error with one mare than max players
 
    printf("with 0 cards in player 0 hand, shuffle should return -1, result is %d\n", actualResult);
    
    
    expectedResult = 0;
    
    for (int c = 1; c < 500; c++){
        
        G.deckCount[0] = c;                         // good shuffle - shuffle player with 1 to 500 cards

        actualResult = shuffle(0, &G);              // shuffle checks that 0 returned with 1 or more cards in player hand

        assert(actualResult == expectedResult);     // checks return error with one mare than max players
    }
    
    printf("with 1 to 500 cards in player 0 hand, shuffle should return 0, result is %d\n", actualResult);
    
    printf ("!!! PASS: shuffle(int player, struct gameState *state) : unittest3.c.\n");
}

int main () {
    testShuffleWithZeroToFiveHundredCardsInDeck();
    return 0;
}